/**
 * @Author: colpu
 * @Date: 2025-03-29 19:38:16
 * @LastEditors: colpu ycg520520@qq.com
 * @LastEditTime: 2025-10-22 09:21:04
 * @
 * @Copyright (c) 2025 by colpu, All Rights Reserved.
 */
import { join } from "path";
import debugFactory from "debug";
const debug = debugFactory("core:loader/mixin/plugin");
import { addDirectory } from "../../utils/index.js";
/**
 * @function loadDirectory 目录加载器, 按目录层次组装并加载
 */
export default async function loadPlugin(ctx) {
  const app = ctx.app;
  const directory = [join(ctx.root, "src/plugins")];
  directory.push(...addDirectory(join(ctx.root, "src/modules"), 'plugins'));
  debug("plugin directory %o", directory);
  const fileLoader = new ctx.FileLoader({
    directory,
    target: {},
    inject: app
  });
  return fileLoader.parseFiles();
}
